package com.gjy.leetcode;

/**
 * 53. 最大子数组和
 *
 * @author 宫静雨
 * @version 1.0
 * @since 2023-03-13 10:15:51
 */
public class B53 {

    public int maxSubArray(int[] nums) {
        int pre = 0;
        int res = nums[0];
        for (int num : nums) {
            pre = Math.max(pre + num, num);
            res = Math.max(res, pre);
        }
        return res;
    }

}
